#include "PacmanFrame.h"

CPacmanAngryFrame::CPacmanAngryFrame()
{
}

CPacmanAngryFrame::~CPacmanAngryFrame()
{
}

void CPacmanAngryFrame::Init()
{
//Frame 1
	m_pPacMesh.LoadXFile("res/pac_boos.x");
	m_PacFrame.AddObject(&m_pPacMesh);
	m_PacFrame.SetPosition(0,0,0);
	m_PacFrame.SetCallback(FC_TogglePac);

	m_pManMesh.LoadXFile("res/man_boos.x");
	m_ManFrame.AddObject(&m_pManMesh);
	m_ManFrame.SetPosition(0,0,0);
	m_ManFrame.SetCallback(FC_ToggleMan);

	m_Frame1.AddFrame(&m_PacFrame);
	m_Frame1.AddFrame(&m_ManFrame);
	m_Frame1.SetPosition(0,0,0);

	
}

void CPacmanAngryFrame::Render()
{
	m_Frame1.Render();	
}

int FC_TogglePac( CZenFrame* pFrame, void* pParameter )
{
	static bool flip = true;
	static double toggle = -0.2;

	// Make sure the frame is valid
	if( !pFrame )
		return E_FAIL;
	
	pFrame->SetPitch(toggle);

	if (flip)
		toggle -= .01;
	else
		toggle += .01;

	if (toggle < -0.5) 
		flip = false;
	
	if (toggle > -0.275) 
		flip = true;
	
	return S_OK;
}
int FC_ToggleMan( CZenFrame* pFrame, void* pParameter )
{
	static bool flip = false;
	static double toggle = 0.2;

	// Make sure the frame is valid
	if( !pFrame )
		return E_FAIL;
	
	pFrame->SetPitch(toggle);

	if (flip)
		toggle -= .01;
	else
		toggle += .01;

	if (toggle < 0.275) 
		flip = false;
	
	if (toggle > 0.5) 
		flip = true;
	
	return S_OK;
}
